package consys.social.core.bo;

import consys.social.core.service.SocialUtils;
import java.io.Serializable;
import java.util.Date;

/**
 * Post contains basic data that we have to know to save and display properly
 *
 * @author Petr Kunc
 */
public abstract class Post implements Serializable {

    private static final long serialVersionUID = -4320394126816238866L;
    private Date date;
    private String text;
    private Entity addedBy;

    public Entity getAddedBy() {
        return addedBy;
    }

    public void setAddedBy(Entity addedBy) {
        this.addedBy = addedBy;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Post other = (Post) obj;

        if (this.date != other.date && (this.date == null || !SocialUtils.dateToString(this.date).equals(SocialUtils.dateToString(other.date)))) {
            return false;
        }
        if ((this.text == null) ? (other.text != null) : !this.text.equals(other.text)) {
            return false;
        }
        if (this.addedBy != other.addedBy && (this.addedBy == null || !this.addedBy.equals(other.addedBy))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 23 * hash + (this.date != null ? this.date.hashCode() : 0);
        hash = 23 * hash + (this.text != null ? this.text.hashCode() : 0);
        hash = 23 * hash + (this.addedBy != null ? this.addedBy.hashCode() : 0);
        return hash;
    }
}
